package org.framework.common.api.websocket.interceptors;

import java.util.Map;

import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;

/**
 * websocket 拦截器
 * <p>描述: </p>
 * <p>Company: Professional</p>
 * @author chanlong(陈龙)
 * @date 2016年5月16日 下午3:09:37
 * @version 1.0.2016
 */
@Component
public class WebSocketInterceptor extends HttpSessionHandshakeInterceptor {

	/**
	 * 前置拦截
	 * @see org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor#beforeHandshake(org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse, org.springframework.web.socket.WebSocketHandler, java.util.Map)
	 * @author chanlong(陈龙)
	 * @date 2016年5月16日 下午3:10:06
	 */
	@Override
	public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler, Map<String, Object> attributes) throws Exception {
		return super.beforeHandshake(request, response, handler, attributes);
	}

	/**
	 * 后置拦截
	 * @see org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor#afterHandshake(org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse, org.springframework.web.socket.WebSocketHandler, java.lang.Exception)
	 * @author chanlong(陈龙)
	 * @date 2016年5月16日 下午3:10:22
	 */
	@Override
	public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler, Exception e) {
		super.afterHandshake(request, response, handler, e);
	}
}
